# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=sasm
_pkgname=SASM
pkgver=3.12.2
pkgrel=1
pkgdesc='A simple crossplatform IDE for NASM, MASM, GAS and FASM assembly languages.'
arch=('x86_64' 'aarch64')
groups=('blackarch' 'blackarch-misc')
url='https://github.com/Dman95/SASM'
license=('custom')
depends=('nasm' 'libxcb' 'gdb' 'qt5-base' 'mesa')
makedepends=('qt4>=4.8')
source=("https://github.com/Dman95/$_pkgname/archive/refs/tags/v$pkgver.tar.gz")
sha512sums=('f96c06fce2a35f9de6c2ed8d82cf3c03d7a9d0cd53bba72ec38f7f8005817733a5ee8d352eba806358f7259334a96f564b1da2c060d9b750545b42385c72854a')

build() {
  cd "$_pkgname-$pkgver"

  qmake QMAKE_CXXFLAGS="$CFLAGS -Wa,--noexecstack -Wl,-z,noexecstack -W \
    -D_REENTRANT -fPIE -fPIC" QMAKE_LFLAGS="-Wl,-z,noexecstack,-fPIC"

  make CXXFLAGS="$CXXFLAGS -Wa,--noexecstack -W -D_REENTRANT -fPIE -fPIC" \
    LDFLAGS="-Wl,-z,noexecstack"
}

package() {
  cd "$_pkgname-$pkgver"

  install -dm 755 "$pkgdir/usr/bin/"
  install -dm 755 "$pkgdir/usr/share/$pkgname"{NASM,Projects,include}
  install -dm 755 "$pkgdir/usr/share/doc/sasm"

  install -Dm 755 sasm "$pkgdir/usr/bin/$pkgname"
  install -Dm 755 Linux/bin/fasm "$pkgdir/usr/bin/fasm"
  install -Dm 755 Linux/bin/listing "$pkgdir/usr/bin/listing"

  install -Dm 644 Linux/share/doc/sasm/* "$pkgdir/usr/share/doc/$pkgname/"
  install -Dm 644 Linux/share/doc/sasm/copyright \
    "$pkgdir/usr/share/licenses/$pkgname/copyright"

  install -Dm 644 Linux/share/sasm/keys.ini "$pkgdir/usr/share/$pkgname/"
  install -Dm 644 Linux/share/sasm/sasm.png "$pkgdir/usr/share/$pkgname/"
  install -Dm 644 Linux/share/sasm/NASM/* "$pkgdir/usr/share/$pkgname/NASM/"
  install -Dm 644 Linux/share/sasm/Projects/* \
    "$pkgdir/usr/share/$pkgname/Projects/"
  install -Dm 644 Linux/share/sasm/include/* \
    "$pkgdir/usr/share/$pkgname/include/"
}

